package com.jiantong.web;


import com.jiantong.user.UserApiAutoConfiguration;
import com.jiantong.web.core.CoreWebConfiguration;
import com.jiantong.web.interceptors.WebLoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
@ComponentScan
@Import({
        CoreWebConfiguration.class,
        UserApiAutoConfiguration.class
})
@EnableWebMvc
@EnableAutoConfiguration
public class WebConfiguration extends WebMvcConfigurerAdapter {

    private final WebLoginInterceptor webLoginInterceptor;

    @Autowired
    public WebConfiguration(WebLoginInterceptor webLoginInterceptor) {
        this.webLoginInterceptor = webLoginInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(webLoginInterceptor);
    }

}
